<template>
	<view class="accountManage">
		<view class="top-box">
			<view class="item-box">
				<view class="item-left">
					<image src="../../static/images/my5.png"></image>
					用户名：
				</view>
				<view class="item-right">
					{{form.nickname}}
				</view>
			</view>
			<view class="item-box">
				<view class="item-left">
					<image src="../../static/images/my5.png"></image>
					证件号：
				</view>
				<view class="item-right">
					{{form.idcard}}

				</view>
			</view>
			<view class="item-box">
				<view class="item-left">
					<image src="../../static/images/my5.png"></image>
					头像：
				</view>
				<view class="item-right">
					<navigator url="/pages/upData/index?type=0" open-type="navigate" hover-class="none">
						<view class="edit-box" >
							点击修改
						</view>
					</navigator>
				</view>
			</view>
			<view class="item-box">
				<view class="item-left">
					<image src="../../static/images/my5.png"></image>
					证书照：
				</view>
				<view class="item-right">
					<navigator url="/pages/upData/index?type=1" open-type="navigate" hover-class="none">
						<view class="edit-box">
							点击修改
						</view>
					</navigator>
				</view>
			</view>
			<view class="item-box">
				<view class="item-left">
					<image src="../../static/images/my5.png"></image>
					身份证正反面：
				</view>
				<view class="item-right">
					<navigator url="/pages/upData/index?type=2" open-type="navigate" hover-class="none">
						<view class="edit-box">
							点击修改
						</view>
					</navigator>
				</view>
			</view>
		</view>
		<view class="bottom-box">
			<view class="b-item-box">
				<view class="b-left-box">
					姓名
				</view>
				<text class="info-box">
					<uv-input border="none" :customStyle="{height:'100%'}" v-model="form.name"
						placeholder="请输入用户名"></uv-input>

				</text>
			</view>
			<view class="b-item-box-two">
				<view class="b-item-info">
					<view class="b-left-box">
						性别
					</view>
					<text class="info-box" @click="showPicker">
						性别--{{form.gender==0?"":''}}
					</text>
				</view>
				<view class="b-item-arrow">
					<uv-icon name="arrow-down" color="#3e3f41"></uv-icon>
				</view>
			</view>
			<view class="b-item-box">
				<view class="b-left-box">
					手机
				</view>
				<view class="search-box">
					<uv-input border="none" :customStyle="{height:'100%'}" v-model="form.mobile"
						placeholder="请输入手机"></uv-input>


				</view>
			</view>
			<view class="b-item-box">
				<view class="b-left-box">
					单位
				</view>
				<text class="info-box">
					<uv-input border="none" :customStyle="{height:'100%'}" v-model="form.danwei"
						placeholder="请输入单位"></uv-input>

				</text>
			</view>
			<view class="b-item-box">
				<view class="b-left-box">
					地址
				</view>
				<text class="info-box">
					<uv-input border="none" :customStyle="{height:'100%'}" v-model="form.address"
						placeholder="请输入地址"></uv-input>

				</text>
			</view>
			<view class="b-item-box-two">
				<view class="b-item-info">
					<view class="b-left-box">
						行业
					</view>
					<text class="info-box" @click="showPicker2">
						煤矿行业
					</text>
				</view>
				<view class="b-item-arrow">
					<uv-icon name="arrow-down" color="#3e3f41"></uv-icon>
				</view>
			</view>
			<view class="b-item-box-two">
				<view class="b-item-info">
					<view class="b-left-box">
						类型
					</view>
					<text class="info-box" @click="showPicker3">
						其他从业人员
					</text>
				</view>
				<view class="b-item-arrow">
					<uv-icon name="arrow-down" color="#3e3f41"></uv-icon>
				</view>
			</view>
			<view class="b-item-box-two">
				<view class="b-item-info">
					<view class="b-left-box">
						学历
					</view>
					<text class="info-box">
						中专
					</text>
				</view>
				<view class="b-item-arrow">
					<uv-icon name="arrow-down" color="#3e3f41"></uv-icon>
				</view>
			</view>
			<view class="b-item-box-three">
				<view class="three-first-box">
					<view class="first-left">
						地址
					</view>
					<view class="first-right" @click="showPro">
						{{form.province||'请选择'}}
						<uv-icon name="arrow-down" color="#3e3f41"></uv-icon>
					</view>
				</view>
				<view class="three-second-box" @click="showPro1">
					{{form.city||'请选择'}}
					<uv-icon name="arrow-down" color="#3e3f41"></uv-icon>
				</view>
				<view class="three-second-box" @click="showPro2">
					{{form.area||'请选择'}}
					<uv-icon name="arrow-down" color="#3e3f41"></uv-icon>
				</view>
			</view>
			<view class="b-item-box">
				<view class="b-left-box">
					邮箱
				</view>
				<view class="search-box">
					<uv-input placeholder="请输入内容" border="none" v-model="form.email" @change="change"></uv-input>
				</view>
			</view>
		</view>
		<view class="backOrSave boxshadow20">
			<view class="back-box">
				<view class="info-box" @click="back">
					<image src="/static/images/my5.png" mode=""></image>
					返回
				</view>
			</view>
			<view class="save-box">
				<view class="info-box" @click="save">
					<image src="/static/images/my5.png" mode=""></image>
					保存
				</view>
			</view>
		</view>
		<uv-picker ref="picker" :columns="cateColumn" @confirm="confirm"></uv-picker>
		<uv-picker ref="picker2" :columns="cateColumn2" @confirm="confirm2"></uv-picker>
		<uv-picker ref="picker3" :columns="cateColumn3" @confirm="confirm3"></uv-picker>

		<uv-picker ref="addpicker" :columns="[provinces]"  keyName="label"
			@confirm="confirm">
		</uv-picker>
		<uv-picker ref="addpicker1" :columns="[citys]"  keyName="label"
			@confirm="confirm1">
		</uv-picker>
		<uv-picker ref="addpicker2" :columns="[areas]"  keyName="label"
			@confirm="confirm2">
		</uv-picker>
	</view>
</template>

<script>
	import city from "@/static/city.json";

	export default {
		data() {
			return {
				cateColumn: [
					['全部', '男', '女', ]
				],
				cateColumn2: [],
				cateColumn3: [],

				form: {
					
					name: '',
					idcard: "",
					zhengshu: "",
					front_image: "",
					back_image: "",
					danwei: "",
					address: "",
					hangye: "",
					leixing: "",
					education: "",
					province: "",
					city: "",
					area: "",
					email: "",
					mobile: "",
					avatar: ""
				},
				loading: true,
				provinces: [], //省
				citys: [], //市
				areas: [], //区
				pickerValue: [0, 0, 0],

			};
		},
		onLoad() {
			this.init()
			console.log(city)
			this.provinces = city
			
		},
		computed: {
			addressList() {
				return [this.provinces, this.citys, this.areas];
			}
		},
		methods: {
			showPro(){
					this.$refs.addpicker.open()
			},
			showPro1(){
					this.$refs.addpicker1.open()
			},
			showPro2(){
					this.$refs.addpicker2.open()
			},
			open() {
				this.$refs.picker.open();
				this.handlePickValueDefault()
			},
			confirm(e) {
				console.log('确认选择的地区：', e);
				this.citys = e.value[0].children
				this.form.province = e.value[0].label
			},
			confirm1(e) {
				console.log('确认选择的地区：', e);
				this.form.city = e.value[0].label
				this.areas = e.value[0].children
			},
			confirm2(e) {
				this.form.area = e.value[0].label
			},
			init() {
				this.$api.userIndex().then(res=>{
					console.log(res)
					this.form =res.data
				})
				this.$api.getEducation().then(res => {
					console.log(res)
				})
				this.$api.getHangYe().then(res => {
					console.log(res)
				})
				this.$api.getLeiXing().then(res=>{
					console.log(res)
				})
			},
			showPicker() {
				this.$refs.picker.open()
			},
			
			showPicker2() {
				this.$refs.picker2.open()
			},
			
			showPicker3() {
				this.$refs.picker2.open()
			},
			confirm3(e) {},

			up(type) {
				uni.navigateTo({
					url:'/pages/upData/index?type='+type
				})
			},
			back(){
				uni.navigateBack()
			},
			save(){
				this.$api.profile(this.form).then(res => {
					console.log(res)
					if (res.code == 1) {
						this.$utils.msg('修改成功')
						setTimeout(() => {
							uni.navigateBack()
						}, 1000)
					} else {
						this.$utils.msg(res.msg)
					}
				})
			}
			
		}

	}
</script>

<style lang="scss" scoped>
	.accountManage {
		padding: 20rpx;

		.top-box {
			width: 100%;
			border-radius: 16rpx;
			margin-bottom: 46rpx;
			background-color: #FFFFFF;

			.item-box {
				width: 100%;
				height: 128rpx;
				border-bottom: 1px solid #f7f7f7;
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 0px 16rpx;
				box-sizing: border-box;

				.item-left {
					height: 44rpx;
					display: flex;
					align-items: center;

					image {
						width: 44rpx;
						height: 44rpx;
						border-radius: 50%;
						margin-right: 8rpx;
					}
				}

				.item-right {
					max-width: 80%;
					overflow-x: hidden;
					color: #a7a9b0;
				}

				.edit-box {
					width: 206rpx;
					color: #222cf1;
					text-align: center;
				}
			}
		}

		.bottom-box {
			width: 100%;
			border-radius: 16rpx;
			background-color: #FFFFFF;
			padding: 16rpx;
			margin-bottom: 26rpx;

			.b-item-box,
			.b-item-box-two {
				width: 100%;
				height: 120rpx;
				border: 1px solid #e6e6e6;
				border-radius: 16rpx;
				display: flex;
				align-items: center;
				padding: 0rpx 12rpx;
				margin-bottom: 24rpx;
				overflow: hidden;

				&:last-child {
					margin-bottom: 0rpx;
				}

				.b-left-box {
					height: 100rpx;
					width: 100rpx;
					background-color: #e5f2fc;
					line-height: 100rpx;
					text-align: center;
					color: #2296e1;
					border-radius: 16rpx;

				}

				.info-box {
					height: 100rpx;
					line-height: 100rpx;
					margin-left: 30rpx;
					display: flex;
				}

				.search-box {
					min-width: 80%;
					margin-left: 8rpx;
				}
			}

			.b-item-box-two {
				display: flex;
				justify-content: space-between;

				.b-item-info {
					display: flex;
				}
			}

			.b-item-box-three {
				width: 100%;
				height: 120rpx;
				margin-bottom: 24rpx;
				display: flex;
				justify-content: space-between;

				.three-first-box {
					width: 290rpx;
					height: 120rpx;
					border: 1px solid #e6e6e6;
					border-radius: 16rpx;
					display: flex;
					align-items: center;
					padding: 0rpx 12rpx;

					.first-left {
						height: 100rpx;
						width: 100rpx;
						background-color: #e5f2fc;
						line-height: 100rpx;
						text-align: center;
						color: #2296e1;
						border-radius: 16rpx;
					}

					.first-right {
						margin-left: 30rpx;
						display: flex;
						width: 50%;
						justify-content: space-between;
					}
				}

				.three-second-box {
					width: 180rpx;
					height: 120rpx;
					border: 1px solid #e6e6e6;
					border-radius: 16rpx;
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding: 0rpx 12rpx;
				}
			}
		}

		.backOrSave {
			width: 100%;
			background-color: #FFFFFF;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0px 12rpx;
			height: 140rpx;
			border-radius: 16rpx;

			.back-box,
			.save-box {
				height: 106rpx;
				width: 336rpx;
				background-color: #e5f2fc;
				border-radius: 16rpx;
				display: flex;
				justify-content: center;
				align-items: center;

				.info-box {
					display: flex;
					justify-content: center;
					align-items: center;
					color: #0484dc;
					font-size: 32rpx;

					image {
						width: 42rpx;
						height: 42rpx;
						margin-right: 24rpx;
					}
				}

			}

			.save-box {
				background-color: #5eb5f1;

				.info-box {
					color: #FFFFFF;
				}
			}
		}
	}
</style>